from ultralytics import YOLO
import os
import cv2
if __name__ == '__main__':
    model = YOLO(r'D:\reduan\model\2025-03-27_01-57-33\2025-03-27_01-57-33.pt')
    testDir=r'D:\reduan\image'
    saveRstDir=r'D:\reduan\rst'
    if not os.path.exists(saveRstDir):
        os.makedirs(saveRstDir)
    imagelist= os.listdir(testDir)
    for one in imagelist:
        fullPath=os.path.join(testDir,one)
        results = model(fullPath, conf=0.25,iou=0.45)
        # if len(results[0].boxes)==0:
        results[0].save(os.path.join(saveRstDir,one))
        # results[0].show()
        # cv2.imwrite(os.path.join(saveRstDir,one),results[0].orig_img)
        